package UILayer;

import java.util.Scanner;

import CtrLayer.KundeCtr;

public class EditKundeUI {
	private KundeCtr kCtr;
	private String phone;
	
	public EditKundeUI()
	{
		kCtr = new KundeCtr();
	}
	
	/**
	 * Prompt user for a Phone no. so you 
	 * dont have to write the phone No. in all the time.
	 * */
	public void startNewEditKundeUI()
	{
		Scanner input = new Scanner(System.in);
		System.out.println("Enter phone No.: ");
		phone = input.next();
		input.nextLine();
		editKundeMenu();
	}
	/**
	 * Main menu for the editKunde UI
	 * */
	public void editKundeMenu()
	{
		boolean start = false;
		while(!start){
			Scanner input = new Scanner(System.in);
			System.out.println("1. Edit Navn");
			System.out.println("2. Edit Konto");
			System.out.println("3. Edit Adresse");
			System.out.println("4. Edit Tlf.");
			System.out.println("5. Edit Rabat");
			System.out.println("6. Edit Email");
		
			int choice = input.nextInt();
			input.nextLine();
			switch(choice){
				case 1:
					editNavn();
					break;
				case 2:
					editKonto();
					break;
				case 3:
					editAdresse();
					break;
				case 4:
					editTlf();
					start = true;
					break;
				case 5:
					editRabat();
					break;
				case 6:
					editEmail();
					break;
					default:
						System.out.println("Leaving Edit Kunde Menu");
						start = true;
						break;
			}
		}
	}
	/**
	 * Edit Navn of a kunde
	 * */
	public void editNavn()
	{
		Scanner input = new Scanner(System.in);
		System.out.println("Current Navn: " + kCtr.findKunde(phone).getNavn());
		System.out.println("Enter new Navn: ");
		String name = input.next();
		kCtr.editNavn(phone, name);
	}
	/**
	 * Edit the Konto of a kunde
	 * */
	public void editKonto()
	{
		Scanner input = new Scanner(System.in);
		System.out.println("Current Konto: " + kCtr.findKunde(phone).getKonto());
		System.out.println("Enter new Konto: ");
		String konto = input.next();
		kCtr.editKonto(phone, konto);
	}
	/**
	 * Edit Addresse of a Kunde
	 * */
	public void editAdresse()
	{
		Scanner input = new Scanner(System.in);
		System.out.println("Current Adresse: " + kCtr.findKunde(phone).getAddresse());
		System.out.println("Enter new Adresse: ");
		String adresse = input.next();
		kCtr.editAdresse(phone, adresse);
	}
	/**
	 * Edit Tlf of a kunde
	 * */
	public void editTlf()
	{
		Scanner input = new Scanner(System.in);
		System.out.println("Current Tlf.: "+ kCtr.findKunde(phone).getTlf());
		System.out.println("Enter new Tlf.: ");
		String tlf = input.next();
		this.phone = tlf;
		kCtr.editTlf(phone, tlf);
	}
	/**
	 * Edit Rabat of a kunde
	 * */
	public void editRabat()
	{
		Scanner input = new Scanner(System.in);
		System.out.println("Current Rabat: " + kCtr.findKunde(phone).getKundeRabat());
		System.out.println("Enter new Rabat: ");
		int rabat = input.nextInt();
		kCtr.editRabat(phone, rabat);
	}
	/**
	 * Edit email of a kunde
	 * */
	public void editEmail()
	{
		Scanner input = new Scanner(System.in);
		System.out.println("Current Email: " + kCtr.findKunde(phone).getEmail());
		System.out.println("Enter new Email: ");
		String email = input.next();
		kCtr.editEmail(phone, email);
	}
}
